/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.eventos.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.general.bc.CapituloFacadeLocal;
import org.cip.esymons.general.be.Capitulo;

/**
 *
 * @author oscar
 */
public class CapituloDelegate {

    CapituloFacadeLocal local;

    public CapituloDelegate() {
        local = lookupCapituloFacade();
    }

    public Capitulo buscar(int capitulo) {
        return local.find(capitulo);
    }

    private CapituloFacadeLocal lookupCapituloFacade() {
        try {
            Context c = new InitialContext();
            return (CapituloFacadeLocal) c.lookup("java:comp/env/CapituloFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<Capitulo> listarTodos() {
        return local.findAll();
    }
}
